<?php

function smarty_outputfilter_cdn($output, &$smarty) {
	global $env, $db, $site;
	
	$cdn_mapping = array_rotate($db->fetchAll("SELECT local, cdn FROM cms_cdn_mapping WHERE site_id=?", $site['id'], Zend_Db::FETCH_NUM));
	
	$output = str_replace($cdn_mapping[0], $cdn_mapping[1], $output);
	
	return $output;
}
$smarty->register_outputfilter('smarty_outputfilter_cdn');
